Imports System.ComponentModel
Imports System.Web.Security

Public Class Questionnaire

    Public Sub New()
    End Sub

    Public Sub New( _
    ByVal id As Integer)
        _id = id
    End Sub

    Private _id As Integer
    Private _desc, _instrumentId, _studyId As String
    Private _editingPerm, _takingPerm As String
    Private _instrument As Instrument
    Private _visitNumber As Byte
    Private _createdDate, _lastUpdated As DateTime
    Private _createdBy, _lastUpdatedBy As String


    <DataObjectField(True)> _
    Public ReadOnly Property ID() As Integer
        Get
            Return _id
        End Get
    End Property

    <DataObjectField(True)> _
    Public Property Description() As String
        Get
            Return _desc
        End Get
        Set(ByVal value As String)
            _desc = value
        End Set
    End Property

    <DataObjectField(True)> _
    Public Property InstrumentID() As String
        Get
            Return _instrumentId
        End Get
        Set(ByVal value As String)
            If String.IsNullOrEmpty(value) Then
                Throw New Exception("Invalid instrumentID.")
            End If
            _instrumentId = value
        End Set
    End Property

    <DataObjectField(True)> _
    Public Property StudyID() As String
        Get
            Return _studyId
        End Get
        Set(ByVal value As String)
            If String.IsNullOrEmpty(value) Then
                Throw New Exception("Invalid studyID.")
            End If
            _studyId = value
        End Set
    End Property

    <DataObjectField(True)> _
    Public Property VisitNumber() As Byte
        Get
            Return _visitNumber
        End Get
        Set(ByVal value As Byte)
            _visitNumber = value
        End Set
    End Property

    <DataObjectField(True)> _
    Public Property EdtingPermission() As String
        Get
            Return _editingPerm
        End Get
        Set(ByVal value As String)
            _editingPerm = value
        End Set
    End Property

    <DataObjectField(True)> _
    Public Property TakingPermission() As String
        Get
            Return _takingPerm
        End Get
        Set(ByVal value As String)
            _takingPerm = value
        End Set
    End Property

    <DataObjectField(True)> _
    Public Property CreatedDate() As DateTime
        Get
            Return _createdDate
        End Get
        Set(ByVal value As DateTime)
            _createdDate = value
        End Set
    End Property

    <DataObjectField(True)> _
        Public Property CreatedBy() As String
        Get
            Return _createdBy
        End Get
        Set(ByVal value As String)
            _createdBy = value
        End Set
    End Property

    <DataObjectField(True)> _
    Public Property LastUpdated() As DateTime
        Get
            Return _lastUpdated
        End Get
        Set(ByVal value As DateTime)
            _lastUpdated = value
        End Set
    End Property

    <DataObjectField(True)> _
    Public Property LastUpdatedBy() As String
        Get
            Return _lastUpdatedBy
        End Get
        Set(ByVal value As String)
            _lastUpdatedBy = value
        End Set
    End Property

    Public ReadOnly Property Instrument() As Instrument
        Get
            If _instrument Is Nothing Then
                If String.IsNullOrEmpty(_instrumentId) Then
                    Throw New Exception("InstrumentID is null.")
                End If
                _instrument = QuestionnaireODS.Provider.GetInstrument(_instrumentId)
            End If
            Return _instrument
        End Get
    End Property
End Class
